package art.up;

public class Coordinate {
	double north,east;
	
	double atanh(double x) {
		return 0.5d*Math.log((1d+x)/(1d-x));
	}
	
	public double getEast() {
		return east;
	}
	
	public double getNorth() {
		return north;
	}
	
	public void setXY(double north, double east) {
		this.north = north;
		this.east = east;
	}
	
	public void WGS84toRT90() {
		double q = north/180d*Math.PI;
		double lambda = east/180d * Math.PI;
		double qstar= q-Math.sin(q)*Math.cos(q)*(0.6694380021e-2 + 0.3729560209e-4*Math.sin(2d*q)+2.592527517e-7*Math.sin(4d*q)+1.971698945e-9*Math.sin(6*q));
		double xfjutt = Math.atan(Math.tan(qstar)/Math.cos(lambda-0.27587170754507245689));
		double nfjutt = atanh(Math.cos(qstar)*Math.sin(lambda-0.27587170754507245689));
		this.north = 6.367484870e6*(xfjutt+0.8377318249e-3*Math.sin(2d*xfjutt)*Math.cosh(2d*nfjutt)+7.608527793e-7*Math.sin(4*xfjutt)*Math.cosh(4d*nfjutt)+1.197638020e-9*Math.sin(6*xfjutt)*Math.cosh(6d*nfjutt)+2.443376245e-12*Math.sin(8d*xfjutt)*Math.cosh(8d*nfjutt))-667.711d;
		this.east  = 6.367484870e6*(nfjutt+0.8377318249e-3*Math.cos(2d*xfjutt)*Math.sinh(2d*nfjutt)+7.608527793e-7*Math.cos(4*xfjutt)*Math.sinh(4d*nfjutt)+1.197638020e-9*Math.cos(6*xfjutt)*Math.sinh(6d*nfjutt)+2.443376245e-12*Math.cos(8d*xfjutt)*Math.sinh(8d*nfjutt))+1500064.274d;
	}
}